package com.gj.serializer;

import com.alibaba.fastjson.JSON;
import com.gj.model.TransactionMessage;
import org.apache.kafka.common.errors.SerializationException;
import org.apache.kafka.common.header.Headers;
import org.apache.kafka.common.serialization.Deserializer;

import java.util.Map;

/**
 * author:guijie
 * date:${date}
 * description:TODO
 */
public class ObjectDeserializer implements Deserializer<TransactionMessage> {

    @Override
    public TransactionMessage deserialize(String s, byte[] bytes) {
        try {
            return bytes == null ? null : JSON.parseObject(bytes,TransactionMessage.class);
        }catch (Exception e){
            throw new SerializationException("反序列化错误");
        }
    }

}
